<template>
	<tm-app ref="app">
		<tm-navbar title="帮手订单确认" color="orange" linear="right" beforeBack="false" hideHome="false"></tm-navbar>
		<tm-result v-if="flag" color="orange" status="success" :title="msg" subTitle=" " btnText="返回首页" :showBtn="true" @click="backIndex()"></tm-result>
		<tm-result v-if="!flag"  color="red" status="warning" :title="msg" subTitle=" " btnText="返回首页" :showBtn="true" @click="backIndex()"></tm-result>
	</tm-app>
</template>

<script lang="ts" setup>
	import { ref } from "vue"
	import { onLoad } from "@dcloudio/uni-app"
	import { isEmpty } from "@/tmui/tool/function/util";
	import { orderTimeMananger } from '@/api/order'
	
	
	const userid = ref("");
	const orderid = ref("");
	const flag = ref(false);
	const msg = ref("数据处理中...");
	onLoad((e) => {
		// console.log(JSON.stringify(e));
		// 进行扫码计时开始和扫码计时结束的请求
		userid.value = uni.getStorageSync("userid");
		if (isEmpty(userid.value)) {
			uni.redirectTo({
				url: '/pages/auth/auth'
			})
		}else{
			orderid.value = e.scene;
			orderIsOpen();
		}
	})
	
	
	const orderIsOpen = async() => {
		let param = {"wxid":userid.value,"orderid":orderid.value};
		const result =  await orderTimeMananger(param);
		console.log(JSON.stringify(result));
		if(result.status){
			flag.value = result.status;
			msg.value = result.msg;
		}else{
			flag.value = result.status;
			msg.value = result.msg;
		}
	}
	
	function backIndex(){
		uni.redirectTo({
			url: '/pages/index/index'
		})
	}
</script>